package com.hisan.freeride.common.Dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.hisan.freeride.R;
import com.hisan.freeride.common.event.DataSynEvent;
import com.hisan.freeride.common.utils.CollectionUtils;
import com.mylhyl.circledialog.BaseCircleDialog;

import org.greenrobot.eventbus.EventBus;

/**
 * 创建时间 : 2017/6/19
 * 创建人：yangyingqi
 * 公司：嘉善和盛网络有限公司
 * 备注：积分兑换验证确认弹窗
 */
public class MallDialogLogout extends BaseCircleDialog implements View.OnClickListener  {
    private View view;
    private static double myprice;

    public static MallDialogLogout getInstance(double price) {
        myprice=price;
        MallDialogLogout dialogFragment = new MallDialogLogout();
        dialogFragment.setCanceledBack(true);
        dialogFragment.setCanceledOnTouchOutside(false);
        dialogFragment.setGravity(Gravity.CENTER);
        dialogFragment.setRadius(4);
        dialogFragment.setWidth(1f);
        return dialogFragment;
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public View createView(Context context, LayoutInflater inflater, ViewGroup container) {
        view=inflater.inflate(R.layout.dialog_logout, container, false);
        return view;
    }







    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.ok) {
            dismiss();
            EventBus.getDefault().post(new DataSynEvent(0));
            //注销逻辑
        } else {
            dismiss();
        }
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        View view = getView();
        view.findViewById(R.id.cancle).setOnClickListener(this);
        view.findViewById(R.id.ok).setOnClickListener(this);
        ImageView iamge= (ImageView) view.findViewById(R.id.logo);
        iamge.setImageResource(R.mipmap.jifen_check);
        TextView tname= (TextView) view.findViewById(R.id.name);
        TextView tcontent= (TextView) view.findViewById(R.id.content);
        tcontent.setText("是否确认兑换？");
        if (!CollectionUtils.isNullOrEmpty(myprice)){
            tname.setText("本次兑换将消耗"+myprice+"个爱心币");
        }
    }
}
